package com.hgyc.mom.mes.entity;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.*;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hgyc.mom.common.annotation.Excel;
import com.hgyc.mom.core.annotation.DictColumn;
import com.hgyc.mom.core.annotation.TableDict;
import com.hgyc.mom.core.mybatis.EQ;
import com.hgyc.mom.core.mybatis.Like;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * <p>
 * 生产工单
 * </p>
 *
 * @author fwj
 * @since 2025-07-10
 */
@Data
@TableName("mes_work_order")
@Schema(name="生产工单对象", description="生产工单对象")
public class MesWorkOrder implements Serializable {
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "工单ID")
    private Long id;

    @Excel(name = "工单编码")
    @EQ
    @Schema(description = "工单编码")
    private String workOrderCode;

    @Excel(name = "工单类型")
    @EQ
    @Schema(description = "工单类型")
    private String workOrderType;

    @EQ
    @Schema(description = "关联产品物料ID")
    @TableDict(table = "base_material", key = "id" , columns = {
            @DictColumn(name = "material_name", alias = "productName")
    })
    private Long productId;

    @Excel(name = "产品编码")
    @Like
    @Schema(description = "产品编码")
    private String productCode;

    @EQ
    @Schema(description = "来源类型")
    private String orderSource;

    @Schema(description = "来源单据")
    private String sourceCode;

    @Excel(name = "生产数量")
    @Schema(description = "生产数量")
    private BigDecimal planQty;

    @Excel(name = "实际完工数量")
    @Schema(description = "实际完工数量")
    private BigDecimal actualQty;

    @Excel(name = "已排产数量")
    @Schema(description = "已排产数量")
    private BigDecimal quantityScheduled;

    @Excel(name = "工艺路线")
    @Schema(description = "工艺路线")
    @TableDict(table = "mes_routing", key = "id" , columns = {
            @DictColumn(name ="name", alias = "routingName"),
    })
    private Long routingId;

    @Excel(name = "车间ID")
    @Schema(description = "车间ID")
    @TableDict(table = "mes_workshop", key = "id" , columns = {
            @DictColumn(name ="name", alias = "workshopName"),
    })
    private Long workshopId;

    @Excel(name = "产线ID")
    @EQ
    @Schema(description = "产线ID")
    @TableDict(table = "mes_workshop", key = "id" , columns = {
            @DictColumn(name ="name", alias = "lineName"),
    })
    private Long lineId;

    @Excel(name = "计划开工时间")
    @Schema(description = "计划开工时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startTime;

    @Excel(name = "计划完工时间")
    @Schema(description = "计划完工时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate endTime;

    @Excel(name = "实际开工时间")
    @Schema(description = "实际开工时间")
    private LocalDateTime actualStartTime;

    @Excel(name = "实际完工时间")
    @Schema(description = "实际完工时间")
    private LocalDateTime actualEndTime;

    @Excel(name = "进度百分比")
    @Schema(description = "进度百分比")
    private BigDecimal progress;

    @Excel(name = "报废数量")
    @Schema(description = "报废数量")
    private BigDecimal scrapQty;

    @Excel(name = "返工数量")
    @Schema(description = "返工数量")
    private BigDecimal reworkQty;

    @EQ
    @Schema(description = "父工单")
    private Long parentId;

    @Excel(name = "单据状态")
    @EQ
    @Schema(description = "单据状态")
    private String status;

    @Schema(description = "同步状态")
    private String syncStatus;

    @Excel(name = "是否完工")
    @Schema(description = "是否完工")
    private String completionFlag;

    @Excel(name = "延迟原因说明")
    @Schema(description = "延迟原因说明")
    private String delayReason;

    @Excel(name = "优先级")
    @Schema(description = "优先级")
    private Long priority;

    @Excel(name = "备注")
    @Schema(description = "备注")
    private String remark;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建者")
    private Long createBy;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.UPDATE)
    @Schema(description = "更新者")
    private Long updateBy;

    @TableField(fill = FieldFill.UPDATE)
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

}